//
//  CJBaseTableViewController.swift
//  SinaWeibo
//
//  Created by 程建 on 16/9/23.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class CJBaseTableViewController: UITableViewController,CJBaseViewDelegate {

    //如果userLogin登入成功,则加载tableView,如果登入失败加载view
    var userLogin = CJUserAccountViewModel.shardAccountViewModel.userLogin
    
    lazy var visitorView:CJBaseView = CJBaseView()
    
    override func loadView() {
        
        if userLogin {
            //tableView
            super.loadView()
        }else{
            //提示用户登录 显示访客视图
            //自定义根视图
            //let visitorView = CJBaseView()
            
            //visitorView.backgroundColor = UIColor.red
            
            //设置根视图 ,根视图的frame在viewWillsubViews方法中设置
            view = visitorView
            //声明代理对象
            visitorView.delegate = self
        }
    }
    
    func userWillLogin() {
        
        //加载授权界面
        //执行线性的操作就用push 打短线性的操作就用modal(模态)
        let oauth = CJOAuthViewController()
    
        let nav = UINavigationController(rootViewController: oauth)
        
        present(nav, animated: true, completion: nil)
        
    }
    
    func userWillReigster() {
        print("用户将要注册")
        print("☺️😝😝😝😝😝😝😝😝😝😝😝😝😝")
    }

    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }

}
